package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mapper.SettingsMapper;
import com.tanhua.model.domain.Question;
import com.tanhua.model.domain.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class SettingsApiImpl implements SettingsApi {

    @Autowired
    private SettingsMapper settingsMapper;

    //查询通知设置
    @Override
    public Settings findByUserId(Long userId) {
        QueryWrapper<Settings> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        return settingsMapper.selectOne(wrapper);
    }

    //添加通知设置
    @Override
    public void saveSettings(Settings setting) {
        settingsMapper.insert(setting);
    }

    //更新设置
    @Override
    public void update(Settings setting) {
        settingsMapper.updateById(setting);
    }
}
